#coding=utf-8
#!/usr/bin/env python

import sys

class bcolors:
    HEADER = '\033[95m'
    OK_BLUE = '\033[94m'
    OK_GREEN = '\033[92m'
    WARING_YELLOW = '\033[93m'
    FAIL = '\033[91m'
    FLASHING = '\033[5m'
    CRITICAL_RED = '\033[31m'
    END = '\033[0m'
    
def guess_age():
    '''
    #输入姓名，姓名不是'Alex'姓名的时候，直接退出程序
    #是'Alex'的时候，输入年龄，29岁，猜测年纪
    #如果用户输入不等于29，给出相应提示，直到用户猜测正确年纪
    #优化程序
    '''
    while True:
        name = raw_input("please input your name: ").strip()
        if len(name) == 0:
            print bcolors.CRITICAL_RED + "Sorry, you can't intype invaild chart, you can re-try again. " + bcolors.END            
            continue
        else:
            if name != 'Alex' and name != 'alex':
                sys.exit(bcolors.CRITICAL_RED + "Sorry, name is wrong, you can re-run the program !!" + bcolors.END)
            else:
                print bcolors.OK_GREEN + "Congratulations, the name is right, please continue~" + bcolors.END
                while True:
                    age = int(raw_input("please input age: "))
                    if age == 29:
                        print bcolors.OK_GREEN + "Yeah, your are right again~" + bcolors.END
                        print bcolors.OK_GREEN + "more features in the future~" + bcolors.END
                        break
                    elif age < 29:
                        print bcolors.WARING_YELLOW + "It's too young, alex is older than %s" %age + bcolors.END
                        continue
                    else:
                        print bcolors.WARING_YELLOW + "It's too old, alex is younger than %s" %age + bcolors.END
            break

def guess_roi():
    name = raw_input("please input your name: ").strip()           
    if len(name) == 0:
        print bcolors.CRITICAL_RED + "Sorry, you can't intype invaild chart, you can re-try again. " + bcolors.END
    else:
        if name != 'Alex' and name != 'alex':
            sys.exit(bcolors.CRITICAL_RED + "Sorry, name is wrong, you can re-run the program !!" + bcolors.END)
        else:
            print bcolors.OK_GREEN + "Congratulations, the name is right, please continue~" + bcolors.END  
            while True:
                age = int(raw_input("please input age: "))
                if age  == 29:
                    print bcolors.OK_GREEN + "Yeah, your are right again. " + bcolors.END
                    print bcolors.OK_GREEN + "more features in the future~" + bcolors.END
                    break
                elif age < 29:
                    print bcolors.WARING_YELLOW + "It's too young, alex is older than %s" %age + bcolors.END
                else:
                    print bcolors.WARING_YELLOW + "It's too old, alex is younger than %s" %age + bcolors.END
        
if __name__ == '__main__':
    guess_age()
    #guess_roi()